<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">&lt;?php
<span id='global-property-'>/**
</span> * Cube PHP Framework
 * 
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the &quot;License&quot;); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * @author Dillen / Steffen
 */

namespace Library\Mvc;

class View
{
<span id='global-property-Array'>	/**
</span>	 * Application configuration
	 * 
	 * @property Array
	 */
	private $_config;
	
<span id='global-property-'>	/**
</span>	 * Router instance
	 * 
	 * @property {Library.Mvc.Router}
	 */
	public $router;

<span id='global-property-S-_memory'>	/**
</span>	 * View memory
	 * 
	 * @property {Array} $_memory
	 * @protected
	 */
	protected $_memory = array();
	
<span id='global-property-S-_overrides'>	/**
</span>	 * Overrides
	 * 
	 * @property {Array} $_overrides
	 * @protected
	 */
	protected $_overrides = array();
	
	public function __construct($config)
	{
		$this-&gt;_config = $config;
	}
	
	public function getElement($id)
	{
		
	}
	
<span id='global-method-'>	/**
</span>	 * Assign memory to the view
	 * 
	 * @param {String} $key
	 * @param {Mixed} $value
	 */
	public function assign($key, $value = null)
	{
		if (is_array($key))
		{
			foreach ($key as $key =&gt; $value)
			{
				$this-&gt;assign($key, $value);
			}
		}
		else
		{
			$this-&gt;_memory[$key] = $value;
		}
	}
	
<span id='global-method-'>	/**
</span>	 * Override view
	 * 
	 * @param {String} $oldView
	 * @param {String} $newView
	 */
	public function override($oldView, $newView)
	{
		$this-&gt;_overrides[$oldView] = $newView;
	}
	
<span id='global-method-render'>	/**
</span>	 * Render view
	 * 
	 * @method render
	 * @param {String} $view
	 */
	public function render($view, array $memory = array(), $path = 'views')
	{
		$this-&gt;assign($memory);
		
		// Check the view first for overrides
		$view = (isset($this-&gt;_overrides[$view])) ? $this-&gt;_overrides[$view] : $view;

		$path = $this-&gt;_config['application']['path'] . $path . '/' . $view;
		
		if (!file_exists($path))
		{
			throw new \Library\IO\Exception\FileNotFoundException('View not found ' . $path);
		}
		
		include $path;
	}
	
<span id='global-method-__get'>	/**
</span>	 * Magic method
	 * 
	 * @method __get
	 * @param {String} $key
	 */
	public function __get($key)
	{
		return isset($this-&gt;_memory[$key]) ? $this-&gt;_memory[$key] : null;
	}
}
</pre>
</body>
</html>
